#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>


#define FIFO_FILE "./fifo"

int main()
{
  umask(0);
  if(-1 == mkfifo(FIFO_FILE,0666)){
    perror("mkfifi");
    return 1;
  }
  int fd = open(FIFO_FILE,O_RDONLY);
  if(fd>=0){
    char buf[64];
    while(1){
      ssize_t s = read(fd,buf,sizeof(buf)-1);
      if(s>0){
        //success read 
        buf[s] = 0;
        printf("client# %s",buf);
      }
      else if(0 == s){
        //todo
        printf("client quit,me too\n");
        break;
      }
      else{
        perror("read");
        break;
      }
    }
  }
}
